//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "ProcessBindingFASTAProfile.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* filenameBindingProfile  = NULL;
  String* filenameListLigands     = NULL;
  String* filenameOut             = NULL;
  
  if (argc < 4) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./FilterResiduesAppearAsLigandInLigandFASTAProfile <In File - Ligand FASTA Profile>";
    cout <<                                                   " <In File - List of Ligands>";
    cout <<                                                   " <Out File>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    filenameBindingProfile  = new String(argv[1]);
    filenameListLigands     = new String(argv[2]);
    filenameOut             = new String(argv[3]);
    
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    cout << " In File - Ligand FASTA Profile : " << argv[1] << endl;
    cout << "      In File - List of Ligands : " << argv[2] << endl;
    cout << "                       Out File : " << argv[3] << endl;
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    
  }
  
  ProcessBindingFASTAProfile* processBindingFASTAProfile = new ProcessBindingFASTAProfile ();
  
  cout << "Preparing Files..." << endl;
  processBindingFASTAProfile->FilenameBindingProfile(filenameBindingProfile);
  processBindingFASTAProfile->FilenameListLigands(filenameListLigands);
  processBindingFASTAProfile->FilenameOut(filenameOut);
  
  cout << "Loading the data..." << endl;
  if (!processBindingFASTAProfile->LoadData())
    cout << "Error Loading data!" << endl;

  cout << "Filtering the residues that appear as Ligands..." << endl;
  processBindingFASTAProfile->FilterChangedResiduesAsLigandHetAtm();
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (processBindingFASTAProfile) delete processBindingFASTAProfile;
  
  if (filenameBindingProfile)     delete filenameBindingProfile;
  if (filenameListLigands)        delete filenameListLigands;
  if (filenameOut)                delete filenameOut;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

